import Vue from 'vue'
import App from './App.vue'
import { datafluxRum } from '@cloudcare/browser-rum';
import { datafluxLogs } from "@cloudcare/browser-logs"

Vue.config.productionTip = false

// 初始化日志 SDK
datafluxLogs.init({
  clientToken: process.env.VUE_APP_CLOUDCARE_CLIENT_TOKEN,
  site: process.env.VUE_APP_CLOUDCARE_SITE,
  service: process.env.VUE_APP_CLOUDCARE_SERVICE,
  env: process.env.VUE_APP_CLOUDCARE_ENV,
  version: process.env.VUE_APP_CLOUDCARE_VERSION,
  forwardErrorsToLogs: false,
})

// 在 new Vue() 之前初始化 SDK，确保更全面的数据采集
datafluxRum.init({
  applicationId: process.env.VUE_APP_CLOUDCARE_APPLICATION_ID,
  site: process.env.VUE_APP_CLOUDCARE_SITE,
  clientToken: process.env.VUE_APP_CLOUDCARE_CLIENT_TOKEN,
  env: process.env.VUE_APP_CLOUDCARE_ENV,
  version: process.env.VUE_APP_CLOUDCARE_VERSION,
  service: process.env.VUE_APP_CLOUDCARE_SERVICE,
  sessionSampleRate: 100,
  sessionReplaySampleRate: 100,
  compressIntakeRequests: true,
  trackInteractions: true,
  traceType: 'ddtrace',
  allowedTracingOrigins: [/.*/],
});
datafluxRum.startSessionReplayRecording()

// 将 datafluxLogs 挂载为全局属性，便于在 vue 中调用
Vue.prototype.$datafluxLogs = datafluxLogs

new Vue({
  render: h => h(App),
}).$mount('#app')
